package com.itheima.controller;

import com.itheima.common.entity.Result2;
import com.itheima.pojo.Dto.OrderDto;
import com.itheima.pojo.Vo.OrderVo;
import com.itheima.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private OrderService orderService;

    /**
     * 预约检查
     * @param orderDto
     * @return
     */
    @PostMapping("/submitOrder")
    public Result2 submitOrder(@RequestBody OrderDto orderDto){
        log.info("用户预约信息：{}",orderDto);
        orderService.submitOrder(orderDto);
        return new Result2(true,"预约成功");
    }
    /**
     * 根据id查询预约信息
     * @param id
     * @return
     */
    @GetMapping("/findById")
    public Result2 findById(Integer id){
        log.info("查询id为{}的预约信息",id);
       OrderVo orderVo = orderService.getById(id);
        return new Result2(true,"查询成功",orderVo);
    }
}
